/*
 * @Author: 灰灰
 * @Date: 2021-12-24 11:31:09
 * @LastEditors: 
 * @LastEditTime: 2021-12-26 16:53:21
 */
import variables from '@/styles/element-variables.scss'
import defaultSettings from '@/settings'

const {
  title,
  showSettings,
  tagsView,
  fixedHeader,
  sidebarLogo
} = defaultSettings

const state = {
  title: title,
  theme: variables.theme,
  showSettings: showSettings,
  tagsView: tagsView,
  fixedHeader: fixedHeader,
  sidebarLogo: sidebarLogo
}

const mutations = {
  CHANGE_SETTING: (state, {
    key,
    value
  }) => {
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  }
}

const actions = {
  changeSetting({
    commit
  }, data) {
    commit('CHANGE_SETTING', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}